package cn.edu.fudan.classifier;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;

import cn.edu.fudan.data.ExtractFeature;
import cn.edu.fudan.data.HandelFeature;
import cn.edu.fudan.data.ReadData;
import cn.edu.fudan.data.WriteData;
import cn.edu.fudan.tools.GetConfig;
import cn.edu.fudan.tools.SimilarityMeasure;
import cn.edu.fudan.type.Config;
import cn.edu.fudan.type.DataItem;
import cn.edu.fudan.type.Feature;

public class CalDistance {

	private static Logger logger = Logger.getLogger(CalDistance.class);

	// private static String path = "D:/DataReader/negativeclass/";

	public static void main(String[] args) throws IOException {

		Config config = new GetConfig().getConfig();

		String path = config.getPath();

		ReadData rData = new ReadData();
		ExtractFeature extractFeature = new ExtractFeature();
		HandelFeature handelFeature = new HandelFeature();
		WriteData writeData = new WriteData();
		SimilarityMeasure similarityMeasure = new SimilarityMeasure();

		int[] sets = new int[] { 103,148,183,260,424,456,511,721,850,878,952,1168,1468,1570,1788,1874,1881,1896,2067,2108,2240,2433,2469,2814,2988,3011,3130,3275,3577,3698,3741,3961,3982,4001,4022,4303,4611,4810,4955,5042,5481,5911,6008,6064,6283,6302,6328,6385,6594,6801,6962,6998,7241,7310,7530,7541,7543,7715,7770,7799,8076,8273,8540,8572,8669,8832,8983,9145,9252,9307,9825,9831,10184,10269,10831,11063,11136,11345,11830,11868,12192,12515,12555,12708,12721,12807,13014,13113,13665,13962,14285,14330,14364,14663,14790,14798,14805,14930,15201,15313
 };

		List<Double> pattern = new ArrayList<>();
		for (int i = 0; i < 100; i++) {
			if (i == 50) {
				pattern.add(1d);
				continue;
			}
			pattern.add(0d);
		}

		// for (int i = 1; i <= 15440; i++) {
		for (int i = 0; i < sets.length; i++) {
			String filepath = path + "data\\" + sets[i];
			List<DataItem> data = new ArrayList<DataItem>();
			try {
				data = rData.readDataFromFile(filepath, true);
			} catch (IOException e) {
			}
			if (data.size() > 0) {
				// Feature feature = extractFeature.getFeature(data,
				// config.getThreshold_window(), config.getProbability(),
				// config.getInterval());
				// List<Double> map =
				// handelFeature.handleFeature(feature.getAbnormal(),
				// config.getN_segment());
				// double distance = similarityMeasure.calEucliDistance(pattern,
				// map);
				// writeData.writeData(path+"feature/map_A",map,i);
				// writeData.writeData(path+"feature/distance_A",distance, i);
				// logger.info(i);
			}
		}

	}
}
